package com.example.upload.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * WebConfig
 *
 * @author ChenJiaGeng
 * @date 2024/10/20 12:50
 * @since 1.0.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/upload/**") // 允许的路径
                .allowedOrigins("http://localhost:5173") // 允许的来源
                .allowedMethods("POST", "GET", "PUT", "DELETE") // 允许的请求方法
                .allowCredentials(true); // 是否允许发送凭据
    }
}
